﻿<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>默认首页APP</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
</head>
<body>
  <div class="layui-form" lay-filter="form-add" id="form-add" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
    <label class="layui-form-label" style="width:100px;">默认首页路径：</label>
    <div class="layui-input-inline">
        <input type="text" name="homepath" value="" style="width:400px;" lay-verify="required" class="layui-input">
    </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="btn_submit" id="btn_submit" value="确定">
    </div>
  </div>
  <script src="/plugins/layui/layui.js"></script>
  <script type="text/javascript" src="/plugins/common/login.js"></script>
  <script>
      layui.config({
          base: '/plugins/layuiadmin/'
      }).extend({
          index: 'lib/index'
      }).use(['index', 'set', 'form'], function () {
          var $ = layui.$, form = layui.form;
          layer.load();
          $.ajax({
              type: "get",
              url: "home_config",
              dataType: "json",
              success: function (res) {
                  if (res.code == 0) {
                      form.val("form-add", res.data);
                      layer.closeAll('loading');
                  }
                  else if (res.code == 110)
                  {
                    layer.closeAll('loading');
                    layer.alert(res.msg, function () {
                        ReLogin();
                    });
                  }
                  else {
                      layer.closeAll('loading');
                      layer.alert(data.msg);
                  }
              }
          });

          form.on('submit(btn_submit)', function (obj) {
              layer.load();
              $.ajax({
                  type: "post",
                  url: "home_config",
                  data: obj.field,
                  dataType: "json",
                  success: function (res) {
                      layer.closeAll('loading');
                      if (res.code == 0) {
                          layer.msg(res.msg, { time: 1 * 1000 });
                      }
                      else if (res.code == 110)
                      {
                        layer.alert(res.msg, function () {
                            ReLogin();
                        });
                      }
                      else {
                          layer.alert(res.msg)
                      }
                  }
              });
              return false;
          });
      });
  </script>
</body>
</html>